<include file="Public/head" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<script src="{:get_style_cdnurl()}paimai/yunying/js/city.js"></script>
<style>
    .select_model{
        -moz-appearance: none;background: rgba(0, 0, 0, 0) url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 115px 5px;
        border: 1px solid #d7d7d7;
        float: left;height: 26px;line-height: 26px;margin-right: 8px;text-indent: 2px;width: 136px;}
    .select2-container .select2-choice {
        background: rgba(0, 0, 0, 0) url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 125px 5px;
        border: 1px solid #d7d7d7;  color: #444;  display: block;  height: 24px;  line-height: 24px;
        overflow: hidden;  padding: 0 0 0 8px;  position: relative;  text-decoration: none;  white-space: nowrap;
        width: 136px;  margin-left:0px;
    }
    .xinxi-conter1 ul li .name-text {  width: 300px;  border-left: none;  }
    .xinxi-conter1 ul li em {border-left: solid 1px #e2e2e2;  }
    .xinxi-conter1 ul li em:first-child {  border-left: none;  }

    #from {
        width: 144px;  height: 24px;  float: left;  line-height: 24px;  margin-right: 10px;;  border: solid 1px #d7d7d7;
        background: #fff url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat 125px 5px;
    }
    #comeFrom {  width: 144px;  height: 24px;  float: left;  line-height: 24px;  border: solid 1px #d7d7d7;
        background: #fff url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat 125px 5px;
    }
    .chexing {  padding-left: 0px;  }
    .chexing span { display: none;  }
    .select2-display-none {width: 160px;  }
    .source ul li{
        border-top:none;}
</style>
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar" menu="yhgz.mcyh" />
    <div class="mianR">
        <h3 class="yonghu">用户基本信息</h3>
        <div class="chezhu-xinxi">
            <div class="xinxi-conter xinxi-conter1">
                <ul>
                    <li>
                        <em>车主姓名</em>
                        <em class="name-text">
                            <input type="text" name="seller_name" id="seller_name" value="" placeholder="请输入姓名"/>
                        </em>
                        <em>车主电话</em>
                        <em class="name-text">
                            <input type="text" id="phone" name="phone" value=""  placeholder="请输入电话号码"/>
                        </em>
                    </li>
                    <li>
                        <em>车型</em>
                        <em class="name-text">
                            <input id="car_modal" name="car_modal" type="text" />
                        </em>
                    </li>
                    <li>
                        <em>车辆所在地</em>
                        <em class="name-text">
                            <select id="location_area" name="location_area" class="branch_company"  style="width: 144px;">
                                <if condition="count($bc_city) gt 1">
                                    <option value="0">请选择所在地</option>
                                </if>
                                <volist name="bc_city" id="city">
                                    <option value="{$key}">{$city}</option>
                                </volist>
                            </select>
                        </em>
                        <em>上牌时间</em>
                        <em class="name-text">
                            <input type="text" id="demoText2" name="frist_reg_date" value="" placeholder="上牌时间" class="yongDi" readonly />
                        </em>
                    </li>
                    <li>
                        <em>行驶里程</em>
                        <em class="name-text">
                            <input id="mileage" type="text" name="mileage" class="yongLi" value="{$owner.mileage}" /><em class="kilometre">公里</em>
                        </em>
                        <em>渠道来源</em>
                        <em class="name-text">
                            <div class="source_input">
                                <input type="text"  name="comefrom" value="" placeholder="请选择渠道来源" readOnly style="width: 245px;"/>
                                <div class="source">
                                    <ul>
                                        <?php foreach($pfrom as $item):?>
                                        <li date="{$item.from_id}">{$item.from_name}</li>
                                        <?php endforeach;?>
                                    </ul>
                                </div>
                                <div class="sourceCity">
                                    <ul>
                                        <foreach name="bc_city" item="vo" key="k">
                                            <li date-city="{$k}">{$vo}</li>
                                        </foreach>
                                    </ul>
                                </div>
                                <div class="sourceTab">
                                    <foreach name="comefrom_list" item="cl" key="k">
                                        <div class="sourceList" date-pid="{$k}">
                                            <ul>
                                                <foreach name="cl" item="clv">
                                                    <li date-id="{$clv.from_id}">{$clv.from_name}</li>
                                                </foreach>
                                            </ul>
                                        </div>
                                    </foreach>

                                    <div class="sourceList siSdian">
                                        <foreach name="city_fours_list" item="cfl" key="k">
                                            <ul style="display: none;" date-code-city="{$k}">
                                                <foreach name="cfl" item="cflv">
                                                    <li date-id="{$cflv.from_id}">{$cflv.from_name}</li>
                                                </foreach>
                                            </ul>
                                        </foreach>
                                    </div>
                                </div>
                            </div>
                            <!--<select id="from" name="from"">-->
                            <!--<option value="">请选择来源</option>-->
                            <!--<volist name="pfrom" id="vo">-->
                                <!--<if condition="($vo['from_id'] neq 2) AND ($vo['from_id'] neq 3) ">-->
                                    <!--<option value="{$vo['from_id']}">{$vo['from_name']}</option>-->
                                <!--</if>-->
                            <!--</volist>-->
                            <!--</select>-->

                            <!--<select id="comeFrom" name="comefrom">-->
                                <!--<option value="">请选择具体来源</option>-->
                            <!--</select>-->

                        </em>
                    </li>
                </ul>
            </div>
        </div>
        <h3 class="yonghu">请选择预约结果</h3>
        <div class="yuyue">
            <ul>
                <li class="yuCurrent" onclick="setStatus(4);">预约成功</li>
                <li onclick="setStatus(2);" >继续跟踪</li>
                <li onclick="setStatus(3);">预约失败</li>
            </ul>
            <input type="hidden" id="business_status" name="business_status" value="4" />
        </div>
        <div class="listBox">
            <div class="yuList">
                <div class="xuanzhe">
                    <ul>
                        <li class="clearfix">
                            <span>预约时间</span>
                            <input type="text" value="" id="reserve_time" class="xiaci"  placeholder="请选择预约时间" readonly />
                        </li>
                        <li class="clearfix">
                            <span>服务方式</span>
                            <span class="menDao">
                                <a href="javascript:setMethod(2);" class="menHover">上门</a>
                                <a href="javascript:setMethod(3);" >到店</a>
                            </span>
                            <input type="hidden" id="service_method" name="service_method"  value="2"/>
                        </li>
                        <li class="clearfix">
                            <span>预约地址</span>
                            <div class="store">
                                <div class="detailed">
                                    <script>var add = new AddressCom('reserve');</script>
                                    <input type="text"  id="reserve_address" name="reserve_address" value="" placeholder="详细地址" class="xiangDi">
                                </div>
                                <div class="detailed" style="display: none;">
                                    <select id="reserve_store" name="reserve_store">
                                        <option value="0">请选择门店</option>
                                        <?php foreach($stores as $key=>$vs):?>
                                        <option value="{$key}">{$vs}</option>
                                        <?php endforeach;?>
                                    </select>
                                </div>

                            </div>
                        </li>
                        <li class="clearfix">
                            <span>备注</span>
                            <textarea id="reserve_remark1" class="remark" name="reserve_remark1" ></textarea>
                        </li>
                    </ul>
                </div>
                <div class="yongBtn1">
                    <input class="submitForm queding" type="button" value="确定" />
                </div>
            </div>
            <div class="yuList" style="display:none;">
                <div class="xuanzhe1">
                    <ul>
                        <li class="genBtn1 clearfix">
                            <span class="gencuur"><font>电话无人接听</font><input type="checkbox" /></span>
                            <span class="gencuur"><font>电话停机或关机</font><input type="checkbox" /></span>
                            <span class="gencuur"><font>最近没时间</font><input type="checkbox" /></span>
                            <span class="gencuur"><font>直接挂断电话</font><input type="checkbox" /></span>
                            <span class="gencuur"><font>需要了解二手车拍卖</font><input type="checkbox" /></span>
                        </li>
                        <li class="clearfix">
                            <span>其他原因</span>
                            <textarea id="trace_remark" class="remark" name="trace_remark" ></textarea>
                        </li>
                        <li class="clearfix">
                            <span>下次跟踪时间</span>
                            <input type="text" value="" id="demoText10" class="xiaci" placeholder="请选择下次跟踪时间" readonly />
                        </li>
                    </ul>
                </div>
                <div class="yongBtn">
                    <input class="submitForm queding" type="button" value="确定"  />
                    <input name="重置" type="reset" class="quxiao" value="重置" />
                </div>
            </div>
            <div class="yuList" style="display:none;">
                <div class="xuanzhe1">
                    <ul>
                        <li class="genBtn1 clearfix">
                            <span class="gencuur" ><font>价格不满意</font><input type="checkbox" /></span>
                            <span class="gencuur" ><font>不想卖了</font><input type="checkbox" /></span>
                            <span class="gencuur" ><font>无法过户</font><input type="checkbox" /></span>
                            <span class="gencuur"><font>车已出售</font><input type="checkbox" /></span>
                            <span class="gencuur"><font>对服务不满意</font><input type="checkbox" /></span>
                            <span class="gencuur"><font>非经营范围</font><input type="checkbox" /></span>
                            <span class="gencuur"><font>超出检测范围</font><input type="checkbox" /></span>
                        </li>
                        <li class="clearfix">
                            <span>其他原因</span>
                            <textarea id="faild_remark" class="remark" name="faild_remark"></textarea>
                        </li>
                    </ul>
                    <input type="hidden" id="reserve_remark" name="reserve_remark" value="">
                </div>
                <div class="yongBtn1">
                    <input class="submitForm queding" type="button"  value="确定" />
                </div>
            </div>
    </div>
</div>
</div>
</div>
<div id="showOption" style="display:none">
    <volist name="from" id="vo">
        <option class="{$vo['pid']}" value="{$vo['from_id']}" >{$vo['from_name']}</option>
    </volist>
</div>
<script type="text/javascript">
    $("body,html").click(function(event) {
        $(".sourceCity").hide();
        $(".sourceTab .sourceList").hide();
        $(".source").hide();
        event.stopPropagation();
    });

    $(".source_input").click(function(event) {
        event.stopPropagation();
    });
    $(".source_input input").val("");
    $(".source_input input").click(function() {
//        $(this).val("");
        if($(".source").css("display")=="none"){
            $(".source").fadeIn();
        }else{
            $(".source").hide();
        }
        $(".sourceCity").hide();
        $(".sourceTab .sourceList").hide();
    });
    var index;
    var text;
    var dateIndex;
    $(".source ul li").click(function() {
        index=$(".source ul li").index(this);
        text=$(this).html();
        dateIndex=$(this).attr("date");
        if(dateIndex==5){
            $(".sourceCity").fadeIn();
            $(".sourceTab .sourceList").hide();
        }else{
            $(".sourceCity").hide();
            $(".sourceTab .sourceList[date-pid='"+dateIndex+"']").fadeIn().siblings().hide();
        }
        $(this).parent().parent().hide();
    });
    var city;
    var cityIndex;
    $(".sourceCity ul li").click(function(i){
        city=$(this).html();
        $(this).parent().parent().hide();
        cityIndex=$(this).attr("date-city");
        $(".sourceTab .siSdian").fadeIn().find("ul[date-code-city='"+cityIndex+"']").fadeIn().siblings().hide();
    })
    $(".sourceList ul li").click(function(){
        $(this).parent().parent().hide();
        if(index==3){
            $(".source_input input").val(text+" - "+city+" - "+$(this).html());
            $(".source_input input").attr("real-value",$(this).attr("date-id"));
        }else{
            $(".source_input input").val(text+" - "+$(this).html());
            $(".source_input input").attr("real-value",$(this).attr("date-id"));
        }
    });



    $(document).ready(function(){
        $("#reserve_time").ymdateplugin({
            showTimePanel: true,
            changeMonth: true,
            changeYear: true,
            gotoCurrent: true,
            ampm:true
        });
    });
    $("#location_area,#reserve_store").select2();
    function setMethod(m) {
        $("#service_method").val(m);
    }

    function setStatus(status) {
        $("#business_status").val(status);
    }

    $(".genBtn1 input").click(function () {
        if ($(this).parent().hasClass("gencuur")) {
            $("#reserve_remark").val($(this).parent().find("font").text());
        } else {
            $("#reserve_remark").val('');
        }
    })

    $(".remark").blur(function () {
        var remark = $(this).val();
        if (remark != '') {
            $("#reserve_remark").val(remark);
        }
    });

    $(".submitForm").click(function () {
        var post_data = {};
        post_data['action'] = 'add';
        post_data['owner_id'] = $("#owner_id").val();
        post_data['seller_name'] = $("#seller_name").val();
        post_data['phone'] = $("#phone").val();
        post_data['location_area'] = $("#location_area").val();
        post_data['first_reg_date'] = $("#demoText2").val();
        post_data['mileage'] = $("#mileage").val();
        post_data['service_method'] = $("#service_method").val();
        post_data['business_status'] = $("#business_status").val();
        post_data['reserve_province'] = $("input[name='province_reserve']").val();
        post_data['reserve_city'] = $("input[name='city_reserve']").val();
        post_data['reserve_area'] = $("input[name='area_reserve']").val();
        post_data['reserve_address'] = $("#reserve_address").val();
        post_data['reserve_store'] = $("#reserve_store").val();
        post_data['reserve_time'] = $("#reserve_time").val();
        post_data['next_trace_time'] = $("#demoText10").val();
        post_data['reserve_remark'] = $("#reserve_remark").val();
        post_data['comefrom'] = $("input[name='comefrom']").attr('real-value');
        /* 车型选择改为输入框
        var model_obj = ModelSelect.get_vals();
        post_data['brand_id'] = model_obj[0]['id'];
        post_data['series_id'] = model_obj[1]['id'];
        post_data['model_id'] = model_obj[2]['id'];
        post_data['car_model'] = model_obj[0]['val'] + " " + model_obj[1]['val'] + " " + model_obj[2]['val'];
        */
        post_data['car_model'] = $("#car_modal").val();
        var btn = $(this);
        btn.attr("disabled", "disabled").css({"background": "#999", "border": "none"}).val("提交中...");
        $.post("/CarOwner/addCarOwner", post_data, function (data) {
            if (data.code != 200) {
                shibai_alert(data.msg, 1500);
                btn.removeAttr("disabled style").val("确定")
                return false;
            }
            btn_alert(data.msg, 1500, function () {
                location.href = document.referrer
            });
        }, "json");
    });

    /** 选择渠道
     * author Heran Liu
     */
    $("#from").change(function () {
        var value = $(this).val(); //获取渠道当前下拉列表选中的值
        //隐藏所有下拉列表的值
        $("#comeFrom option").each(function () {
            if ($(this).val() != '') {
                $(this).remove();
            }
        });

        //显示具体渠道下拉列表
        $("#showOption option").each(function () {
            if ($(this).val() == '' || $(this).attr("class") == value) { //通过判断class名称判断是否显示
                $("#comeFrom").append($(this).clone(true)); //为Select追加一个Option(下拉项)
                if ($(this).val() == '') {
                    $(this).prop("selected", true)
                }
            }
        });

    });

</script>
</body>
</html>
